package com.cpe.transfer.member;

import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Component;
import org.springframework.util.Assert;

import com.cpe.data.domain.member.Member;
import com.cpe.data.domain.member.MemberInfo;

import jodd.util.StringUtil;

@Component
public class MemberTransfer {
	/**
	 * 实体-->响应
	 */
	public MemberInfo toInfo(Member member) {
		Assert.notNull(member);
		MemberInfo info = new MemberInfo();
		BeanUtils.copyProperties(member, info);
		info.setCreator(member.getCreatorRef());
		String mobile = info.getMobile();
		if (StringUtil.isNotBlank(mobile)) {
			info.setMobileAbbr(mobile.substring(0, 3) + "***" + mobile.substring(7, 11));
		}
		return info;
	}
}
